package com.jersey;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.ws.rs.core.MediaType;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.http.entity.StringEntity;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;

public class JerseyClientDemo {
	public static void main(String[] args) throws HttpException, IOException {
		ClientConfig cc = new DefaultClientConfig();
		cc.getClasses().add(MyJaxb.class);
		Client c = Client.create(cc);

		DealBean deal = new DealBean();
		deal.setTitle("abc");
		MerchantBean m = new MerchantBean();

		MyJaxb feed = c.resource("http://172.20.230.27:9081/d/deal/s").accept(MediaType.APPLICATION_XML).type(
				MediaType.APPLICATION_XML).post(MyJaxb.class,
				new MyJaxb("1", "b"));

		MyJaxb feed1 = c.resource("http://172.20.230.27:9081/d/deal/ss")
				.accept(MediaType.APPLICATION_XML).type(
						MediaType.APPLICATION_XML).post(MyJaxb.class);
		//		
		// HttpClient h = new HttpClient();
		// PostMethod pm = new PostMethod("http://172.20.230.27:9081/d/deal/s");
		// pm.setRequestBody("abc");
		// int re = h.executeMethod(pm);
		// DealFeedData feed =
		// r.type(MediaType.APPLICATION_XML).entity(deal).post(
		// DealFeedData.class);

		// System.out.println(feed.getDeal());
	}
}
